{extend name="base"}
{block name="title"}代理注册申请{/block}
{block name="head"}
<style>
  .border-table tbody th{text-align:center; color:#333; font-weight:400; padding-left:5px;}
  .border-table{font-size:12px; color:#666;}
  .border-table th, .border-table td{text-align:center; padding:0 4px;}
</style>
{/block}
{block name="body"}
<body class="mainbody">
<form>
  <!--导航栏-->
  <div class="location">
    <a href="javascript:history.back(-1);" class="back"><i class="iconfont icon-up"></i><span>返回上一页</span></a>
    <a href="{:url('index/home')}" class="home"><i class="iconfont icon-home"></i><span>首页</span></a>
    <i class="arrow iconfont icon-arrow-right"></i>
    <span>代理注册申请</span>
  </div>
  <!--/导航栏-->

  <!--工具栏-->
  <div id="floatHead" class="toolbar-wrap">
    <div class="toolbar">
      <div class="box-wrap">
        <a class="menu-btn"><i class="iconfont icon-more"></i></a>
        <div class="l-list">
          <div class="menu-list">
            <div class="rule-single-select">
              <select name="channel" style="display:none">
                <option value="-1"> ===所有渠道=== </option>
                {volist name="CHANNELS" id="val"}
                <option value="{$key}" {eq name="channel" value="$key"} selected{/eq}>[{$key}]{$val.Name}</option>
                {/volist}
              </select>
            </div>
            <input type="text" class="input rule-date-input" id="time1" autocomplete="off" {literal}onclick="WdatePicker({maxDate:'#F{$dp.$D(\'time2\')}'})"{/literal} name="time1" value="{$time1|default=''|substr=0,10}" /> -
            <input type="text" class="input rule-date-input" id="time2" autocomplete="off" {literal}onclick="WdatePicker({minDate:'#F{$dp.$D(\'time1\')}', maxDate:'%y-%M-%d'})"{/literal} name="time2" value="{$time2|default=''|substr=0,10}" />&nbsp;
            <div class="rule-single-select">
              <select name="state" style="display:none">
                <option value="-1"> ===所有状态=== </option>
                <option value="0"{eq name="state" value="0"} selected{/eq}>等待审核</option>
                <option value="1"{eq name="state" value="1"} selected{/eq}>审核通过</option>
              </select>
            </div>
            <input type="text" class="keyword" autocomplete="off" name="search" value="{$search|default=''|htmlentities}" placeholder="UserID/GameID/昵称"/>
            <a class="btn-search"><i class="iconfont icon-search"></i></a>
          </div>
        </div>
      </div>
    </div>
  </div>
  <!--/工具栏-->

  <!--列表-->
  <div class="table-container">
    <table class="ltable border-table">
      <tr>
        <th>渠道号</th>
        <th>#</th>
        <th>用户标识</th>
        <th>游戏标识</th>
        <th>真实姓名</th>
        <th>绑定人数</th>
        <th>身份证</th>
        <th>手机号码</th>
        <th>登陆密码</th>
        <th>提交时间</th>
        <th>提交IP</th>
        <th>状态</th>
        <th>操作</th>
      </tr>
{empty name="list"}
      <tr><td colspan="13">Oh~暂无数据!</td></tr>
{else/}
    {volist name="list" id="v"}
      <tr data-id="{$v.ID}">
        <td>[{$v.Channel}]{$CHANNELS[$v.Channel]['Name'] ?? '--'}</td>
        <td>{$v.ID}</td>
        <td>{$v.UserID}</td>
        <td>{$v.GameID}</td>
        <td><a target="_blank" href="{:url('user.detail/index')}?UserID={$v.UserID}">{$v.Compellation|htmlentities}</a></td>
        <td><a target="_blank" href="{:url('user.agent.bind/index')}?search2={$v.GameID}">{$v.BindCount}</a></td>
        <td>{$v.PassPortID}</td>
        <td>{$v.MobilePhone}</td>
        <td>{$v.LogonPass}</td>
        <td>{$v.Addtime}</td>
        <td><a href="http://www.baidu.com/s?wd={$v.IP}" target="_blank">{$v.IP}</a></td>
        <td style="color:{eq name='v.Status' value='1'}green{else/}red{/eq}">{$v.Status?'审核通过':'等待审核'}</td>
        <td>
          {eq name="v.Status" value="0"}<input type="button" value="同意" class="ty" />{/eq}
          <input type="button" value="重置密码" class="gm" />
          <!-- <input type="button" value="补发" class="bf" /> -->
          <!-- {eq name="v.Status" value="1"}<input type="button" value="后台" class="ht" />{/eq} -->
          <!-- <input type="button" value="删除" class="sc" /> -->
        </td>
      </tr>
    {/volist}
{/empty}
    </table>
  </div>
  <!--/列表-->

  <!--内容底部-->
  <div class="page-footer"><div class="btn-wrap">{$list->render()}</div></div>
  <!--/内容底部-->

</form>
<script>
$(function () {
  // 同意推广员的申请
  $('table.ltable input.ty').click(function (e) {
    var id = $(this).parents('tr').data('id');
    console.log(id);
    dialog({
      title: "提示",
      content: "是否确认同意申请?",
      okValue: '确定',
      ok: function () {
        $.post("{:url('agree')}?id=" + id, function (resp, text, xhr) {
          alert(resp.error);
          if (resp.errno == 0) {
            location.reload();
          }
        });
      }
    }).showModal();
  });
  // 删除推广员的相关信息
  $('table.ltable input.sc').click(function (e) {
    var id = $(this).parents('tr').data('id');
    dialog({
      title: "提示",
      content: "是否删除该代理及相关数据?",
      okValue: '确定',
      ok: function () {
        $.post("{:url('delete')}?id=" + id, function (resp, text, xhr) {
          alert(resp.error);
          if (resp.errno == 0) {
            location.reload();
          }
        });
      }
    }).showModal();
  });
  // 重置密码
  $('table.ltable input.gm').click(function (e) {
    var id = $(this).parents('tr').data('id');
    dialog({
      title: "提示",
      content: "是否重置id=" + id + "用户的密码?",
      okValue: '确定',
      ok: function () {
        $.post("{:url('resetpwd')}?id=" + id, function (resp, text, xhr) {
          alert(resp.error);
          if (resp.errno == 0) {
            location.reload();
          }
        });
      }
    }).showModal();
  });
});
</script>
</body>
{/block}